package cn.apptec.test.ssm.service.impl;

import cn.apptec.test.ssm.annotation.SwitchDS;
import cn.apptec.test.ssm.dao.employees.EmployeesMapper;
import cn.apptec.test.ssm.dao.local.UserMapper;
import cn.apptec.test.ssm.enumeration.DatasourceEnum;
import cn.apptec.test.ssm.model.employees.Employees;
import cn.apptec.test.ssm.model.local.User;
import cn.apptec.test.ssm.service.UserService;
import cn.apptec.test.ssm.utils.DataSourceContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("userService")
//@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private EmployeesMapper employeesMapper;

    @Override
    public User getUserById(int userId) {
        return this.userMapper.selectByPrimaryKey(userId);
    }


    @SwitchDS(DatasourceEnum.EMPLOYEES)
    @Override
    public Employees test() {
        Employees employees = employeesMapper.hello(10001);
        return employees;
    }

}